<script lang="ts">
  import { authenticate } from '@/store/modules/account/info';
  import { defineComponent, PropType } from 'vue';

  export default defineComponent({
    name: 'Authority',
    props: {
      visible: {
        type: Boolean,
        default: function (): boolean {
          return true;
        },
      },
      authorities: {
        type: Array as PropType<string[]>,
        default: function (): string[] {
          return [];
        },
      },
    },
    computed: {
      isShow: function (): boolean {
        return this.visible && authenticate(this.authorities, this.$store.getters['account/info'].authorities);
      },
    },
    render() {
      return this.isShow ? this.$slots.default?.() : undefined;
    },
  });
</script>
